package com.bwie.student.service.impl;

import com.bwie.common.domain.Student;
import com.bwie.common.domain.request.StudentRequest;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.student.config.FastUtil;
import com.bwie.student.mapper.StudentMapper;
import com.bwie.student.service.StudentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;


    @Autowired
    private FastUtil fastUtil;

    @Override
    public Result<PageResult<Student>> showStudent(StudentRequest studentRequest) {

        PageHelper.startPage(studentRequest.getPageNum(),studentRequest.getPageSize());

        List<Student> students = studentMapper.showStudent(studentRequest);

        PageInfo<Student> studentPageInfo = new PageInfo<>(students);

        return PageResult.toResult(studentPageInfo.getTotal(),students);

    }


}
